<template>
  <view
    class="content"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#FFFFFF"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text" @click="down">游历</view>
    </view>
    <view style="padding: 0 30rpx">
      <view class="inp">
        <u--input
          placeholder="搜索目的地"
          border="none"
          placeholderStyle="font-size:30rpx;color:#ADADAD;"
          prefixIcon="search"
          prefixIconStyle="font-size: 42rpx;color: #ADADAD"
          color="#ADADAD"
          v-model="value"
          @change="change"
          inputAlign="left"
        ></u--input>
      </view>
    </view>

    <scroll-view
      class="box"
      :scroll-y="true"
      @scroll="scroll"
      :style="{
        height: scrollHeihgt + 'px',
      }"
    >
      <view
        class="box_item"
        @click="toDetail(item.id, item.name)"
        v-for="(item, index) in list"
        :key="index"
        :style="{
          'background-image': 'url(' + item.file_url + ')',
        }"
      >
        <view class="item_title"> {{ item.name }}/{{ item.pinyin }} </view>
        <view class="item_text">
          <image src="@/static/images/icon_ta.png" mode=""></image>
          {{ item.jingdian_count }}个景区
        </view>
      </view>
      <view class="empty_view" v-if="list && list.length == 0">
          <image
            class="item_left_clickable"
            src="../../static/images/my/kong.png"
            mode=""
          ></image>
          <view >当前没有相关数据，请查看其他分类或功能。~</view>
        </view>
      <view style="height: 100rpx"></view>
    </scroll-view>


    <floatingBall></floatingBall>
  </view>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      scrollHeihgt: 0,
      value: "",
      list: [],
    };
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度

    this.statusBarHeight = statusBarHeight.statusBarHeight;
    const windowHeihgt = statusBarHeight.windowHeight - this.statusBarHeight;
    // this.$nextTick(() => {
    //   uni
    //     .createSelectorQuery()
    //     .select(".head")
    //     .boundingClientRect((data) => {
    //       this.height = data.height;
    //     })
    //     .exec();
    // });

    this.$nextTick(() => {
      const query = uni.createSelectorQuery().in(this);
      query.select(".head").fields({
        size: true,
      });
      query.select(".inp").fields({
        size: true,
      });

      query.exec((data) => {
        let sum = 0;
        data.forEach((item) => {
          sum += item.height;
        });
        this.scrollHeihgt = windowHeihgt - sum;
        this.height = data[0].height;
        console.log(windowHeihgt, "总高度");
        console.log(this.scrollHeihgt, "滚动区高度");
        console.log(this.height, "头部高度");
      });
    });

    // this.getList("");
  },
  onLoad() {},
  onShow: function () {
    this.getList(this.value);
  },
  methods: {
    toDetail(id, name) {
      uni.navigateTo({
        url: `/pages/integral/myTravelDetail?id=${id}&name=${name}&type=my`,
      });
    },
    tabClick(e) {
      this.current = e.index;
    },

    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    getList(search) {
      this.$http
        .usergongnengYouLi({ search: search })
        .then((res) => {
          console.log(res.data.list, "游历");
          this.list = res.data.list;
        })
        .catch((error) => {
          uni.$u.toast(error);
        });
    },
    change() {
      this.getList(this.value);
    },
    scroll() {},
  },
};
</script>

<style scoped lang="scss">
.content {
  position: fixed;
  box-sizing: border-box;
  background: url("/static/images/index.png") no-repeat;
  background-size: 100% 100%;
}

.head {
  width: 100%;
  padding: 18rpx 30rpx 47rpx;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  z-index: 99;

  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .head_right {
    position: absolute;
    right: 30rpx;
    font-size: 30rpx;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    color: #55b877;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #ffffff;
  }
}
.inp {
  width: 100%;
  height: 80rpx;
  background: rgba(39, 44, 41, 0.5);
  border-radius: 40rpx 40rpx 40rpx 40rpx;
  padding: 0 248rpx;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  margin-top: 32rpx;
  margin-bottom: 32rpx;
}
.box {
  width: 100%;
  padding: 0 30rpx;
  box-sizing: border-box;

  .box_item {
    width: 100%;
    height: 288rpx;
    // background: url("/static/images/pic_yl_one.png") no-repeat;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 40rpx;
    box-sizing: border-box;
    margin-bottom: 20rpx;
    .item_title {
      font-size: 40rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #eeeeee;
    }
    .item_text {
      margin-top: 12rpx;
      font-size: 26rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #eeeeee;
      display: flex;
      align-items: center;
      image {
        width: 20rpx;
        height: 28rpx;
        margin-right: 8rpx;
      }
    }
  }
}
.empty_view {
  margin-top: 300rpx;
  image {
    margin: 0 auto;
    width: 410rpx;
    height: 410rpx;
  }
  view {
    font-size: 30rpx;
    color: #d8d8d8;
    text-align: center;
  }
}
</style>